import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [

  {
    path: "/",
    name: "layout",
    meta: {
      title: "布局",
      hidden: true
    },
    redirect: "/newsList",
    component: () => import( '../components/Layout/index'),
    children: [
      {
        path: "newsList",
        name: "newsList",
        meta: {
          title: "新闻列表",
          icon: require("@/assets/navBarIcon/newsList_icon.png"),
          iconSel: require("@/assets/navBarIcon/newsList_icon_sel.png")
        },
        component: () => import( '../views/newsList.vue')
      },
      {
        path: "newsType",
        name: "newsType",
        meta: {
          title: "新闻分类",
          icon: require("@/assets/navBarIcon/newsType_icon.png"),
          iconSel: require("@/assets/navBarIcon/newsType_icon_sel.png")
        },
        beforeEnter: (to, from, next) => {
          
          next()
         
        },
        component: () => import( '../views/newsType.vue')
      },
      {
        path: "users",
        name: "users",
        meta: {
          title: "用户管理",
          icon: require("@/assets/navBarIcon/users_icon.png"),
          iconSel: require("@/assets/navBarIcon/users_icon_sel.png")
        },
        component: () => import( '../views/users.vue')
      },
      {
        path: "swiperMgr",
        name: "swiperMgr",
        meta: {
          title: "轮播管理",
          icon: require("@/assets/navBarIcon/swiper_icon.png"),
          iconSel: require("@/assets/navBarIcon/swiper_icon_sel.png")
        },
        component: () => import( '../views/swiperMgr.vue')
      },
      {
        path: "worker",
        name: "worker",
        meta: {
          title: "员工管理",
          icon: require("@/assets/navBarIcon/worker_icon.png"),
          iconSel: require("@/assets/navBarIcon/worker_icon_sel.png")
        },
        component: () => import( '../views/worker.vue')
      },
    ]
  },
  {
    path: "/login",
    name: "login",
    meta: {
      title: "登录",
      hidden: true
    },
    component: () => import( '../views/login.vue')
  }
]

const router = new VueRouter({
  routes
})


router.beforeEach((to, from, next) => {
 
  document.title = "龚十一公司_" + to.meta.title
  
  next()
})


router.afterEach((to, from) => {
 
})

export default router
